<template>
  <div :id="id" :class="className" :style="{ height: height, width: width }" />
</template>

<script>
import * as echarts from "echarts";
import resize from "./mixins/resize";

export default {
  mixins: [resize],
  props: {
    className: {
      type: String,
      default: "chart",
    },
    id: {
      type: String,
      default: "chart",
    },
    width: {
      type: String,
      default: "1500px",
    },
    height: {
      type: String,
      default: "800px",
    },
  },
  data() {
    return {
      chart: null,
    };
  },
  mounted() {
    this.initChart();
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart.dispose();
    this.chart = null;
  },
  methods: {
    initChart() {
      this.chart = echarts.init(document.getElementById(this.id));
      const xData = (function () {
        const data = [];
        for (let i = 1; i < 13; i++) {
          data.push(i + "month");
        }
        return data;
      })();
      this.chart.setOption({
        title: {
          text: "Stacked Area Chart",
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#6a7985",
            },
          },
        },
        // legend: {
        //   data: ["Email", "Union Ads", "Video Ads", "Direct", "Search Engine"],
        // },
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
        series: [
          {
            name: "Email",
            type: "line",
            stack: "Total",
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [120, 132, 101, 134, 90, 230, 210],
          },
          {
            name: "Union Ads",
            type: "line",
            stack: "Total",
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [220, 182, 191, 234, 290, 330, 310],
          },
          {
            name: "Video Ads",
            type: "line",
            stack: "Total",
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [150, 232, 201, 154, 190, 330, 410],
          },
          {
            name: "Direct",
            type: "line",
            stack: "Total",
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [320, 332, 301, 334, 390, 330, 320],
          },
          {
            name: "Search Engine",
            type: "line",
            stack: "Total",
            label: {
              show: true,
              position: "top",
            },
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [820, 932, 901, 934, 1290, 1330, 1320],
          },
        ],
      });
    },
  },
};
</script>
/** 销售金额 */
@Excel(name = "销售金额")
private Double salesAmount;

/** 退款金额 */
@Excel(name = "退款金额")
private Double returnAmount;

/** 净销售额 */
@Excel(name = "净销售额")
private Double netSalesAmount;

/** 总销售件数 */
@Excel(name = "总销售件数")
private Integer totalSalesNumber;

/** 净销售件数 */
@Excel(name = "净销售件数")
private Integer netSalesNumber;

/** 发货前退货件数 */
@Excel(name = "发货前退货件数")
private Integer returnBeforeShipmentNumber;

/** 发货后退货件数 */
@Excel(name = "发货后退货件数")
private Integer returnAfterShipmentNumber;

/** 总退货件数 */
@Excel(name = "总退货件数")
private Integer totalReturnNumber;

/** 综合退货率 */
@Excel(name = "综合退货率")
private Double comprehensiveReturnRate;

/** 毛利额 */
@Excel(name = "毛利额")
private Double grossProfit;

/** 毛利率 */
@Excel(name = "毛利率")
private Double grossProfitRate;

/** 期末库存 */
@Excel(name = "库存")
private Integer endingInventory;

/** 告罄率 */
@Excel(name = "售罄率")
private Double exhaustionRate;

/** 上架时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date newTime;

/** SD单件数 */
@Excel(name = "SD单件数")
private Integer sdNumber;

/** MJX单件数 */
@Excel(name = "MJX单件数")
private Integer mjxNumber;


@Excel(name = "图片",sort=2,height = 100,cellType = Excel.ColumnType.IMAGE)
private String PicFullUrl;

/** 返回给前端的x轴 **/
private String payDateUnit;

/** 可售天数 */
@Excel(name = "可售天数")
private Integer saleDays;

/** i是否是新品 */
    @Excel(name = "是否是新品")
    private String isNew;

//    /** 小趋势图 */
//    private TendencyChart tendencyChart;

    /** 序号 */
    private Integer serialNumber;

    /** 商品折扣率 */
    @Excel(name = "商品折扣率")
    private Double discountRateGoods;

    private String dataDateUnit;

    /** 花费 */
    @Excel(name = "花费")
    private Double cost;

    /** 成交金额 */
    @Excel(name = "成交金额")
    private Double totalFinishAmount;

    /** 3天销售量 */
    @Excel(name = "3天销售量")
    private Integer threeSaleNum;

    /** 7天销售量 */
    @Excel(name = "7天销售量")
    private Integer sevenSaleNum;

    /** 15天销售量 */
    @Excel(name = "15天销售量")
    private Integer fifteenSaleNum;

    /** 30天销售量 */
    @Excel(name = "30天销售量")
    private Integer thirtySaleNum;